package com.ephra.dao.servlet.user;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ephra.commons.ResultMessage;
import com.ephra.dao.factory.Factory;

public class SelectAll extends HttpServlet{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -1353050584137139706L;

	public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException {
		response.setContentType("text/json;charset=UTF-8");
	    response.setCharacterEncoding("UTF-8");
	    PrintWriter out=response.getWriter();
	    String str ="{\"data\":\"ERROR\"}";
		try {
			if(!Factory.getUser().selectAll().isEmpty()){
				str ="{\"data\":\"SUCCESS\"}";
			}
			out.println(str);
			out.flush();
			out.close();
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}
	
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
		this.doGet(request, response);
	}
}
